const express = require('express')
const deleteOrder = express.Router()
const db = require('../../mysql/db')

function query(id) {
    return new Promise((resolve, reject) => {
        db.query(`DELETE FROM orders WHERE orderID = ${id};`, (err, results) => {
            if (err) {
                reject(err);
                console.log(err);
            } else {
                console.log("删除成功！");
            }
        });
    });
}
deleteOrder.post('/deleteOrder', (req, res) => {
    const result = query(req.body.id);
    res.send({
        code: 200, // 0 表示处理成功，1 表示处理失败
        message: 'post 请求成功！', // 状态的描述
        result: result, // 需要响应给客户端的数据
    });
});
module.exports = deleteOrder
